//
//  OnlineFileAssetTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by apple on 17/9/4.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "OnlineFileAssetTableViewCell.h"

@implementation OnlineFileAssetTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initMyCell];
    }
    return self;
}


-(void)initMyCell{
    [self.contentView addSubview:self.fileImageView];
    [self.contentView addSubview:self.fileNameLabel];
    //点击查看label
    UILabel * theDetailLabel = [ToolClass creatLabelWithFrame:CGRectMake([UIScreen zj_screenWith] - ItemWidth * 204, ItemHeight * 14, ItemWidth * 180, ItemHeight * 60) font:14 textColor:[UIColor zj_colorWithHexString:@"f24141"] text:@"点击查看文件"];
    theDetailLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:theDetailLabel];
    [self.contentView addSubview:self.bottomView];
}


-(void)setModel:(LPActDetailResouceModel *)model
{
    _model = model;
    self.fileNameLabel.text = model.NAME;
    if ([model.NAME containsString:@".doc"] || [model.NAME containsString:@".docx"]) {
        self.fileImageView.image = [UIImage imageNamed:@"icon_doc"];
    }
    else if ([model.NAME containsString:@".xls"] || [model.NAME containsString:@".xlsx"]) {
        self.fileImageView.image = [UIImage imageNamed:@"icon_xls"];
    }
    else if ([model.NAME containsString:@".jpg"] || [model.NAME containsString:@".jpeg"] || [model.NAME containsString:@".gif"] || [model.NAME containsString:@".png"]) {
        self.fileImageView.image = [UIImage imageNamed:@"icon_jpg"];
    }
    else{
        self.fileImageView.image = [UIImage imageNamed:@"icon_unknow"];
    }
}


-(UIImageView *)fileImageView
{
    if (!_fileImageView) {
        _fileImageView = [[UIImageView alloc]initWithFrame:CGRectMake(ItemWidth * 29, ItemHeight * 20, ItemWidth * 36, ItemHeight * 48)];
    }
    return _fileImageView;
}


-(UILabel *)fileNameLabel
{
    if (!_fileNameLabel) {
        _fileNameLabel = [ToolClass creatLabelWithFrame:CGRectMake(ItemWidth * 83, ItemHeight * 14, [UIScreen zj_screenWith] - ItemWidth * 300, ItemHeight * 60) font:16 textColor:[UIColor textBlackColor] text:@""];
    }
    return _fileNameLabel;
}


-(UIView *)bottomView
{
    if (!_bottomView) {
        _bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, ItemHeight * 85, [UIScreen zj_screenWith], ItemHeight * 3)];
        _bottomView.backgroundColor = [UIColor themeGrayColor];
    }
    return _bottomView;
}


@end
